﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Iacym.Entities;

namespace Iacym.Repository.Mapping
{
    public class ESTUDIOS_BIBLICOSMap : EntityTypeConfiguration<ESTUDIOS_BIBLICOS>
    {
        public ESTUDIOS_BIBLICOSMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            // Table & Column Mappings
            this.ToTable("ESTUDIOS_BIBLICOS");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.PersonaId).HasColumnName("PersonaId");
            this.Property(t => t.LibroId).HasColumnName("LibroId");

            // Relationships
            this.HasRequired(t => t.LIBRO)
                .WithMany(t => t.ESTUDIOS_BIBLICOS)
                .HasForeignKey(d => d.LibroId);
            this.HasRequired(t => t.PERSONA)
                .WithMany(t => t.ESTUDIOS_BIBLICOS)
                .HasForeignKey(d => d.PersonaId);

        }
    }
}
